# get rid of that stupid cache mechanism
rm -f config.cache

m4_define([v_maj], [0])
m4_define([v_min], [0])
m4_define([v_mic], [1])
m4_define([v_ver], [v_maj.v_min.v_mic])

m4_define([lt_cur], m4_eval(v_maj + v_min))
m4_define([lt_rev], v_mic)
m4_define([lt_age], v_min)

AC_INIT([eina_extra], [v_ver], [enesim-devel@googlegroups.com])
AC_PREREQ([2.60])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_USE_SYSTEM_EXTENSIONS

AM_INIT_AUTOMAKE([1.6 dist-bzip2])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_USE_SYSTEM_EXTENSIONS

LT_PREREQ([2.2])
LT_INIT([win32-dll])

version_info="lt_cur:lt_rev:lt_age"
AC_SUBST([version_info])
AC_DEFINE_UNQUOTED([VERSION_MAJOR], [v_maj], [Major version])
AC_DEFINE_UNQUOTED([VERSION_MINOR], [v_min], [Minor version])
AC_DEFINE_UNQUOTED([VERSION_MICRO], [v_mic], [Micro version])

VMAJ=v_maj
AC_SUBST([VMAJ])


### Additional options to configure

### Needed information

AC_CANONICAL_HOST

### Checks for programs

AC_PROG_CC

# pkg-config
PKG_PROG_PKG_CONFIG

# Check whether pkg-config supports Requires.private
if ! $PKG_CONFIG --atleast-pkgconfig-version 0.22; then
   AC_MSG_ERROR([pkg-config >= 0.22 is required])
fi

# doxygen program for documentation building
ENS_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"])


### Checks for libraries

efl_version="1.7.0"

requirements_cflags=""
requirements_libs=""
requirements_pc=""

## Windows

case "$host_os" in
   mingw*)
      PKG_CHECK_EXISTS([evil >= ${efl_version}],
         [
          requirements_pc="${requirements_pc} evil >= ${efl_version}"
          AC_DEFINE([HAVE_EVIL], [1], [Define to 1 if you have Evil library.])
         ],
         [AC_MSG_ERROR([Evil is required. Be sure to have it installed.])])
   ;;
esac

## Eina

requirements_pc="eina >= ${efl_version} ${requirements_pc}"
PKG_CHECK_MODULES([EINA_EXTRA], [${requirements_pc}])

### Checks for header files

### Checks for types


### Checks for structures


### Checks for compiler characteristics

AC_C_BIGENDIAN
AM_PROG_CC_C_O
ENS_CHECK_COMPILER_FLAGS([EINA_EXTRA], [-Wall -Wextra -Wshadow -Wpointer-arith -Wno-missing-field-initializers -fvisibility=hidden -fdata-sections -ffunction-sections])

### Checks for linker characteristics

ENS_CHECK_LINKER_FLAGS([EINA_EXTRA], [-fvisibility=hidden -Wl,--no-copy-dt-needed-entries])
# FIXME: what about : -fdata-sections -ffunction-sections -Wl,--gc-sections -fno-strict-aliasing ?

### Checks for library functions

# Unit tests, coverage and benchmarking

### Substitutions

AC_SUBST([requirements_cflags])
AC_SUBST([requirements_libs])
AC_SUBST([requirements_pc])
EINA_EXTRA_CFLAGS="${EINA_EXTRA_CFLAGS} ${requirements_cflags} -DEINA_EXTRA_EXTENSION ${ENS_SIMD_FLAGS} ${ENS_COVERAGE_CFLAGS}"
EINA_EXTRA_LIBS="${EINA_EXTRA_LIBS} ${requirements_libs} ${ENS_COVERAGE_LIBS}"


## Make the debug preprocessor configurable

AC_CONFIG_FILES([
Makefile
])

AC_OUTPUT

#####################################################################
## Info

echo
echo
echo
echo "------------------------------------------------------------------------"
echo "$PACKAGE $VERSION"
echo "------------------------------------------------------------------------"
echo
echo
echo "Configuration Options Summary:"
echo
echo "Compilation.................................: make (or gmake)"
echo "  CPPFLAGS..................................: $CPPFLAGS"
echo "  CFLAGS....................................: $CFLAGS"
echo "  LDFLAGS...................................: $LDFLAGS"
echo
echo "Installation................................: make install (as root if needed, with 'su' or 'sudo')"
echo "  prefix....................................: $prefix"
echo
